#include "courier.h"
#include "ui_courier.h"

Courier::Courier(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Courier)
{
    ui->setupUi(this);
    ui->pushButton_2->setDisabled(true);
    socket = SocketManager::getinstance().socket();

    connect(socket,&QAbstractSocket::readyRead,this,[&](){
        emit(rigfinish());
    });

}

Courier::~Courier()
{
    delete ui;
}

void Courier::on_pushButton_clicked()
{
    emit(returnregister());
}
//用户条例是否确认的判断
void Courier::on_checkBox_stateChanged(int arg1)
{
     if(arg1==0)
     {
         ui->pushButton_2->setDisabled(true);
     }
     else
     {
         ui->pushButton_2->setDisabled(false);
     }
}
//快递员注册功能
void Courier::on_pushButton_2_clicked()
{
    sendRig rig;
    rig.type = 0;//快递员注册标志
    const char * account = ui->lineEdit->text().toUtf8().constData();
    strcpy(rig.Account,account);
    const char * password = ui->lineEdit_2->text().toUtf8().constData();
    strcpy(rig.password,password);
    const char * telenum = ui->lineEdit_3->text().toUtf8().constData();
    strcpy(rig.tele,telenum);
    rig.IC = ui->lineEdit_4->text().toInt();
    rig.Idtype = false;
    QByteArray data;
    data.append((char*)&rig,sizeof (sendRig));
    socket->write(data);
}
